#include "../LogSystem/senlog.h"
#include <iostream>
#include <unistd.h>

void test()
{
    senlog::Logger::ptr logger = senlog::LoggerManager::GetInstance().getLogger("Async_logger");
    logger->debug("%s", "测试日志");
    logger->info("%s", "测试日志");
    logger->debug("%s", "测试日志");
    logger->debug("%s", "测试日志");
    logger->debug("%s", "测试日志");

    // size_t count = 0;
    // while(count < 500000)
    // {
    //     logger->fatal("测试日志 - %d", count++);
    // }

    // DEBUG("%s", "测试日志");
    // INFO("%s", "测试日志");
    // WARN("%s", "测试日志");
    // ERROR("%s", "测试日志");
    // FATAL("%s", "测试日志");

    // size_t count = 0;
    // while(count < 500000)
    // {
    //    FATAL("测试日志 - %d", count++);
    // }
}
int main()
{
    std::unique_ptr<senlog::LoggerBuilder> builder(new senlog::GlobalLoggerBuilder());
    builder->buildLoggerName("Async_logger");
    builder->buildLimitValue(senlog::LogLevel::value::WARN);
    builder->buildFormatterPtr("[%c][%f:%l]%m%n");
    builder->buildLoggerType(senlog::LoggerType::ASYN_LOGGER);
    builder->buildEnableUnsafe();

    builder->buildSink<senlog::FileLogSink>("./logfile/async.log");
    builder->buildSink<senlog::StdoutLogSink>();
    builder->buildSink<senlog::RollLogSink>("logsfile/roll-async-by-size", 1024*1024);
    builder->build();
    test();
}